import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[] array = {1,2,34,3,4,5,7,23,12};
        // int[] array = {2,6,4,1};
        boolean ret = hasThreeOdds(array);
        System.out.println(ret);
    }

    public static boolean hasThreeOdds(int[] array){
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i] % 2 == 0){
                count = 0;
                continue;
            }
            count++;
            if(count == 3){
                return true;
            }
        }
        return false;
    }

    public static void main7(String[] args) {
        int[] array = new int[]{2,2,2,1,1,1,2,1,1};
        int ret = manyNum(array);
        System.out.println(ret);
    }

    public static int manyNum(int[] array){
        int max = 0;
        int min = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i] > array[max]){
                max = i;
            }else if(array[i] < array[min]){
                min = i;
            }
        }

        int[] count = new int[10];
        for (int i = 0; i < array.length; i++) {
            count[array[i]-array[min]]++;
        }

        int manyNumi = 0;
        for (int i = 0; i < count.length; i++) {
            if(count[i] > array.length/2){
                manyNumi = i;
            }
        }
        return manyNumi + array[min];
    }

    public static void main6(String[] args) {
        int[] array = {2,7,11,15};
        int[] ret = new int[10];

        ret = sumTarget(array, 26);
        String str = Arrays.toString(ret);
        System.out.println(str);

    }

    public static int[] sumTarget(int[] array, int target){
        int[] ret = new int[2];
        int begin = 0;
        boolean flag = false;
        for (int j = 0; j < array.length ; j++) {
            for (int i = 0; i < array.length; i++) {
                if(j != i && array[j] + array[i] == target){
                    while(begin < 2){
                        ret[begin++] = j;
                        ret[begin++] = i;
                    }
                    flag = true;
                }
            }
        }

        if(flag == false){
            return null;
        }else{
            return ret;
        }

    }

    public static int findSingal(int[] array){
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }

    public static void main5(String[] args) {
        int[] array = {4,1,2,1,2};
        int ret = findSingal(array);
        System.out.println(ret);
    }

    public static void main4(String[] args) {
        int[] array = {9,8,7,6,3,4,0,2,1,5};
        bubbleSort(array);
        printArray(array);
    }

    public static void bubbleSort(int[] array){
        boolean flag = true;
        for (int j = 0; j < array.length-1; j++) {
            for (int i = 0; i < array.length-1-j; i++) {
                if(array[i] > array[i+1]){
                    int tmp = array[i];
                    array[i] = array[i+1];
                    array[i+1] = tmp;
                    flag = false;
                }
            }
            if(flag == true){
                break;
            }
        }
    }

    public static void main3(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9,10};
        int ret = binarySearch(array, 6);
        System.out.println(array[ret]);
    }

    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9,10};
        partitionOddEven(array);
        printArray(array);
    }

    public static void main1(String[] args) {
        int[] array = {1,2,3};
        transform(array);
        printArray(array);
    }

    public static void printArray(int[] arr){
        for (int x: arr) {
            System.out.print(x + " ");
        }
        System.out.println();
    }
    public static void transform(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            arr[i] *= 2;
        }
    }

    public static void partitionOddEven(int[] arr){
        int[] ret = new int[arr.length];
        int j = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] % 2 != 0){
                ret[j++] = arr[i];
            }
        }

        for (int i = 0; i < arr.length; i++) {
            if(arr[i] % 2 == 0){
                ret[j++] = arr[i];
            }
        }

        for (int i = 0; i < ret.length; i++) {
            arr[i] = ret[i];
        }
    }

    public static int binarySearch(int[] array, int x){
        int left = 0;
        int right = array.length-1;
        while(left < right){
            int mid = (left+right)/2;
            if(array[mid] < x){
                left = mid + 1;
            }else if(array[mid] > x){
                right--;
            }else {
                return mid;
            }
        }
        return -1;
    }
}
